package com.china08.yxyapi.config;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * RabbitMQ:保持活跃
 * 
 * @author Administrator
 *
 */
@Configuration
@EnableScheduling
public class RabbitQueueKeepAliveConfig {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Scheduled(cron = "*/1 * * * * *")
    public void send() {
        rabbitTemplate.convertAndSend(//
                RabbitQueueConfig.YW_QUEUE_KEEP_ALIVE, System.currentTimeMillis() + ":FROM:YW"//
        );
    }

    @RabbitListener(queues = RabbitQueueConfig.YW_QUEUE_KEEP_ALIVE)
    public void receive01() {
    }

}
